package think.in.java.concurrency.PractiseOneMoreTime;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by richard on 5/4/14.
 */
public class Exec9ThreadPrioroties {
    public static void main(String[] args){
        ExecutorService executorService = Executors.newFixedThreadPool(10);
        List<Thread> threadList = new ArrayList<Thread>();
        for(int i=0 ; i <10 ; i++){
            Thread thread = new Thread(new ThreadProperties());
            thread.setPriority(10-i);
            threadList.add(thread);
        }
        for(Thread thread : threadList){
            executorService.submit(thread);
        }
        executorService.shutdown();
    }
}

class ThreadProperties implements Runnable{

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName() + " running.");
        for(;;){
            Thread.yield();
        }

    }
}
